package com.dingreading.cloud.app.service.impl;

import com.dingreading.cloud.app.entity.StoreSignIn;
import com.dingreading.cloud.app.entity.table.StoreSignInTableDef;
import com.dingreading.cloud.app.mapper.StoreSignInMapper;
import com.dingreading.cloud.app.service.StoreSignInService;
import com.mybatisflex.core.query.QueryCondition;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 服务层实现。
 *
 * @author Administrator
 * @since 2023-11-22
 */
@Service
public class StoreSignInServiceImpl extends BaseServiceImpl<StoreSignInMapper, StoreSignIn, StoreSignInTableDef> implements StoreSignInService {

    @Override
    protected StoreSignInTableDef getTable() {
        return StoreSignInTableDef.storeSignIn;
    }

    @Resource
    StoreSignInMapper storeSignInMapper;

    /**
     * 根据会员id、状态记录、日期获取
     *
     * @param memberId 会员id
     * @param status   状态记录
     * @param timeYmd  日期
     * @return list
     */
    @Override
    public List<StoreSignIn> getByMemberIdAndStatusAndTimeYmd(Long memberId, Integer status, String timeYmd) {
        QueryCondition condition = QueryCondition.createEmpty();
        condition.and(table.memberId.eq(memberId));
        if (status != null) {
            condition.and(table.status.eq(status));
        }
        condition.and(table.arrivalTime.likeLeft(timeYmd));
        return getMapper().selectListByCondition(condition);
    }

}
